<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    class Person {
      constructor(name, age) {
        this.name = name;
        this.age = age;
      }

      running() {
        console.log("running 方法");
      }
    }

    class Student extends Person {
      constructor(name, age, sno) {
        super(name, age)
        this.sno = sno;
      }
    }


    const stu = new Student("why", 18, 110);
    console.log(stu.name, stu.age, stu.sno);
    stu.running()


    class Teacher extends Person {
      constructor(name, age, title) {
        // 子类中必须初始化父类对象
        super(name, age)
        this.title = title;
      }
    }

    const techer = new Teacher("kobe", 40, "教练")
    console.log(techer.name, techer.age, techer.title);
    techer.running()

  </script>
</body>

</html>